<?php
/**
 * X11 toolkit
 *
 * @package Deenzo
 */

// No direct access
defined( "__DEENZO__" ) or die( "deenzo$" );

// Loading dependencies
coreutil( "string" ) or kill( "string$" );

/* Register IS like functions */
function is_function( $func, $call ) {

    if ( is_string( $func ) )
        $func = preg_split( "/(,\s?)/", $func );
        
   
    /** Register IS-like functions */  
    foreach ( (array) $func as $e ) {
        
        $e = str_replace( array( "-", "." ), array( "_", "_" ), $e );
    
        if ( $e and !function_exists( "is_$e" ) )
            eval( "function is_$e() { return $call( '$e' ); }" );
        
            
    }
    
}

/* Return TRUE if current X11 template is used */
function is_page( $page ) {

    $X11 = preg_split( "/\./", __X11__ );
    
    /** Return TRUE if page is current */
    foreach ( $X11 as $__ )
        if ( $__ == $page )
            return true;
            
    return false; 

}

/* Prints Language Attributes */
function language_attributes( $enctype = "html" ) {

    $lc_lang = str_replace( "_", "-", sysconfig( "lc_lang" ) );
    
    $att[ "dir" ] = sysconfig( "lc_dir" );
    
    if ( $enctype == "html" )
        $att[ "lang" ] = $lc_lang;
    else
        $att[ "xml:lang" ] = $lc_lang;
        
    echo att( $att, "-x" );
    
}

/* SET or PRINT page title */
function title( $sitename = "" ) {

    /* Set session SITENAME */
    if ( $sitename )
        env( "X11.sitename", $sitename );
    
    /* Echoes SITENAME */
    else {
        
        if ( !env("X11.sitename") )
            env( "X11.sitename", sysconfig( "sitename" ) );
            
        echo env( "X11.sitename" );
    
    }
}